home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 1996 May: Tool Chest / Developer CD Series May 1996 (Tool Chest) (Apple Computer) (1996).iso / Tool Chest / Text / WASTE / WASTE 1.1.2 Distribution / Demo Source / WEICSupport.p < prev    next >
Encoding:
Text File  |  1995-10-12  |  2.0 KB  |  101 lines  |  [TEXT/CWIE]

  1. unit WEICSupport;
  2.  
  3. { WASTE DEMO PROJECT: }
  4. { Internet Config Support }
  5.  
  6. { Copyright © 1995 Marco Piovanelli }
  7. { All Rights Reserved }
  8.  
  9. interface
  10.     uses
  11.         WASTE;
  12.  
  13. { ICAwareWEClick is a version of WEClick which supports command+clicking of URLs }
  14. { through Internet Config }
  15.  
  16.     procedure ICAwareWEClick (hitPt: Point;
  17.                                     modifiers: Integer;
  18.                                     clickTime: LongInt;
  19.                                     we: WEReference);
  20.  
  21. implementation
  22.     uses
  23.         ICAPI, LowMem;
  24.  
  25.     procedure ICAwareWEClick (hitPt: Point;
  26.                                     modifiers: Integer;
  27.                                     clickTime: LongInt;
  28.                                     we: WEReference);
  29.         label
  30.             1;
  31.         const
  32.             kGenericCreator = '????';
  33.         var
  34.             ic: ICInstance;
  35.             hText: Handle;
  36.             selStart, selEnd: LongInt;
  37.             junklong: LongInt;
  38.             i: Integer;
  39.             saveTextState: SignedByte;
  40.             err: ICError;
  41.     begin
  42.         ic := nil;
  43.  
  44. { first let WEClick do its thing }
  45.         WEClick(hitPt, modifiers, clickTime, we);
  46.  
  47. { if this isn't a command+click in an active WE instance, we're finished }
  48.         if (BAND(modifiers, cmdKey) = 0) | (WEIsActive(we) = false) then
  49.             goto 1;
  50.  
  51. { try to start start Internet Config }
  52.         err := ICStart(ic, kGenericCreator);
  53.         if (err <> noErr) then
  54.             goto 1;
  55.  
  56. { find the IC preferences file }
  57.         err := ICFindConfigFile(ic, 0, nil);
  58.         if (err <> noErr) then
  59.             goto 1;
  60.  
  61. { get current selection range }
  62.         WEGetSelection(selStart, selEnd, we);
  63.  
  64. { get a handle to the raw text }
  65.         hText := WEGetText(we);
  66.  
  67. { lock it }
  68.         saveTextState := HGetState(hText);
  69.         HLock(hText);
  70.  
  71. { parse the URL and fetch it using the appropriate helper application }
  72.         err := ICLaunchURL(ic, '', hText^, GetHandleSize(hText), selStart, selEnd);
  73.  
  74. { unlock the text }
  75.         HSetState(hText, saveTextState);
  76.  
  77. { highlight the URL }
  78.         WESetSelection(selStart, selEnd, we);
  79.  
  80. { flash the URL if successful }
  81.         if (err = noErr) then
  82.             begin
  83.                 for i := LMGetMenuFlash - 1 downto 0 do
  84.                     begin
  85.                         Delay(5, junklong);
  86.                         WEDeactivate(we);
  87.                         Delay(5, junklong);
  88.                         WEActivate(we);
  89.                     end;  { for }
  90.             end
  91.         else
  92.             SysBeep(30);
  93.  
  94. 1:
  95. { clean up }
  96.         if (ic <> nil) then
  97.             if (ICStop(ic) <> noErr) then
  98.                 ;
  99.     end;  { ICAwareWEClick }
  100.  
  101. end.